Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@automationcloud/request

Package Overview
Dependencies
Maintainers
6
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@automationcloud/request

An HTTP client

  • 3.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
6
Created
Source

@automationcloud/request

import { Request } from '@automationcloud/request';

const request = new Request({
  baseUrl: 'https://example.com',
  headers: {
    'common-headers': 'foo'
  },

});

// JSON request shortcuts
const json = await request.post('/foo', {
  query,
  headers,
  body,
});

// Generic
const response = await request.post({
  method: 'POST',
  url: '/bar',
  headers: { ... },
  body: string | Buffer | URLSearchParams,
});

Request Options

all options are optional, values used below example are default values.

const request = new Request({
    // The base url
    baseUrl: 'https://example.com',

    // auth agent. when you want it to manage the auth stuff.
    // e.g. BasicAuthAgent will set headers.authorization = `Basic ...` automatically when sending a request
    auth: new NoneAuthAgent();

    // default to 10.
    retryAttempts: 10;

    // interval between retries
    retryDelay: 500,

    // The HTTP response status codes that will automatically be retried.
    // Along with status codes, requests will be retried when it fails with predefined network error codes
    // see NETWORK_ERRORS in  src/main/request.ts
    statusCodesToRetry: [401, 429, [502, 504]],

    // The HTTP response status codes that will invalidate the auth.
    // It's going to be used by AuthAgent that implements invalidate method, such as OAuth2Agent
    statusCodeToInvalidateAuth: [401, 403],

    // some default headers to add to requests
    headers: {},

    // fetch module - default to node-fetch
    fetch: nodeFetch,

    // callback function which will be called on retry
    onRetry: () => {},

    // callback function which will be called on error
    onError: () => {},
});

Keywords

FAQs

Package last updated on 14 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc